# Copyright (c) 2009 by Alex Leone <acleone ~at~ gmail.com>
#
# This file is part of epp.
#
# epp is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# epp is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with epp.  If not, see <http://www.gnu.org/licenses/>.

import os
import tag

FILE_EXT = '.py'
SKIP = ('__init__.py', 'tag.py', 'errors.py')

__all__ = ["tag", "errors"]
builtin_tags = {}
for f in sorted(os.listdir(__path__[0])):
    if f.endswith(FILE_EXT) and f not in SKIP:
        modulename = f[:-len(FILE_EXT)]
        __all__.append(modulename)
        __import__('tags.' + modulename)
        #exec("import %s" % (modulename))
        classname = modulename[1:].capitalize()
        taginst = eval("%s.%s()" % (modulename, classname))
        tagnames = eval("%s.tagnames" % (modulename))
        for tagname in tagnames:
            builtin_tags[tagname] = taginst